<!-- $Id: sale_stats.htm 16420 2014-09-11 08:46:42 王海龙 $ -->
{include file="pageheader.htm"}
<!--图表-->
{insert_scripts files="ichart.1.2.min.js"}
{insert_scripts files="ichart.data.js"}
<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<div class="main-div">
  <p style="margin: 10px">
    <strong>有效订单总金额</strong>:&nbsp;&nbsp;{$order_general.total_turnover}&nbsp;&nbsp;&nbsp;
    <strong>有效订单总数</strong>:&nbsp;&nbsp;{$order_general.total_order_num}&nbsp;&nbsp;&nbsp;
  </p>
</div>

<div class="form-div">
  <form action="" method="post" id="selectForm" name="selectForm">
    开始日期 
    <input name="start_date" value="{$start_date}" style="width:150px;" onclick="return showCalendar(this, '%Y-%m-%d %H:%M', '24', false, this);" />
    结束日期 
    <input name="end_date" value="{$end_date}" style="width:150px;" onclick="return showCalendar(this, '%Y-%m-%d %H:%M', '24', false, this);" /><br />
    <!-- {foreach from=$region_arr item=item key=key} -->
      <input type="checkbox" name="regions[]" value="{$item.region_id}" {if $item.checked eq 1}checked="checked"{/if}> {$item.region_name}　
      {if $key eq 15}<br />{/if}
    <!-- {/foreach} -->
    <br />
    <input type="submit" name="submit" value="提交" class="button" />
  </form>
</div>
<div class="tab-div">
 <div id="tabbar-div">
    <p>
      <span class="tab-front" id="order_region-tab">订单地区分布</span>
      <span class="tab-back" id="order_date-tab">订单日期分布</span>
      <span class="tab-back" id="order_fee-tab">订单金额分布</span>
      <span class="tab-back" id="everyday_PL-tab">每日盈亏统计</span>
      <span class="tab-back" id="weight_region-tab">重量地区分布</span>
      <span class="tab-back" id="pay_region-tab">支付地区分布</span>
      <span class="tab-back" id="trench_region-tab">购买渠道分析</span>
      <span class="tab-back" id="profit_time_region-tab">用户统计分析</span>
    </p>
 </div>
 <div id="tabbody-div">
    <table width="90%" cellspacing="0" cellpadding="3" border="1" id="order_region-table" class="stable">
      <caption align="center" class="title">
        各地区订单情况
      </caption> 
<!--各省订单情况-->
      <tr >
        <td>地区</td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  <= 15}<td align="center">{$item.name}</td>{/if}
        <!-- {/foreach} -->
      </tr>
      <tr>
        <td>订单量</td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  <= 15}<td align="center">{$item.sum}</td>{/if}
        <!-- {/foreach} -->
      </tr>    
      <tr>
        <td>占有率</td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  <= 15}<td align="center">{$item.rate}%</td>{/if}
        <!-- {/foreach} -->
      </tr>
      <tr>
        <td></td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  > 15 && $smarty.foreach.foo.index < 32}<td align="center">{$item.name}</td>{/if}
        <!-- {/foreach} -->
      </tr>
      <tr>
        <td>订单量</td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  > 15 && $smarty.foreach.foo.index < 32}<td align="center">{$item.sum}</td>{/if}
        <!-- {/foreach} -->
      </tr>    
      <tr>
        <td>占有率</td>
        <!-- {foreach from=$region_stats item=item key=key name=foo} -->
        {if $smarty.foreach.foo.index  > 15 && $smarty.foreach.foo.index < 32}<td align="center">{$item.rate}%</td>{/if}
        <!-- {/foreach} -->
      </tr> 
<!--各省订单情况 END-->

<!--仓库发货情况-->
      <tr>
        <table  width="15%" cellspacing="0" cellpadding="3" id="order_region-table" border="1" class="stable" >
          <caption align="center" class="title">仓库发货情况</caption>
          <tr><td>{$region_stats.stock.0.area}</td><td>{$region_stats.stock.0.sum}</td></tr>
          <tr><td>{$region_stats.stock.1.area}</td><td>{$region_stats.stock.1.sum}</td></tr>
        </table>
      </tr>
<!--仓库发货情况 END-->
    </table>
    <table width="90%" cellspacing="0" cellpadding="3" id="order_date-table" style="display:none" border="1" class="stable" >
      <caption align="center" class="title">
        订单日期分布
      </caption>
      <tr align="center" bgcolor="#DDEEF2">
        <td>地区\日期</td>
        {foreach from=$order_date.time item=item}
          <td>{$item.date}</td>
        {/foreach}
        <td>总单量</td>
      </tr>
      <!-- {foreach from=$order_date.data item=items} -->
      <tr align="center">
        <!--{foreach from=$items item=item key=key}--> 
        <td>{$item}</td>  
        <!--{/foreach}-->
      </tr> 
      <!-- {/foreach} -->
    </table>
    <table width="90%" cellspacing="0" cellpadding="3" id="order_fee-table" style="display:none;" border="1" class="stable">
      <caption align="center" class="title">
        订单金额分布
      </caption>
      <tr align="center" bgcolor="#DDEEF2" height=40 style="margin-top:20px">
        <td></td>
        <td>金额区间</td>
        <td>0~49</td>
        <td>50~99</td>
        <td>100~149</td>
        <td>150~199</td>
        <td>200~249</td>
        <td>250~299</td>
        <td>300~349</td>
        <td>350~399</td>
        <td>400~</td>
      </tr>
      
      <tr align="center">
        <td></td>
        <td>订单量</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.cnt}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>总金额</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.amount}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>纯利润</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.all_pure}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>盈利单数</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.profit_cnt}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>盈利金额</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.profit_pure}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>亏损单数</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.deficit_cnt}</td>
        <!-- {/foreach} -->
      </tr>

      <tr align="center">
        <td></td>
        <td>亏损金额</td>
        <!-- {foreach from=$amount_interval item=item key=key} -->
        <td>{$item.deficit_pure}</td>
        <!-- {/foreach} -->
      </tr>
        
       
      
    </table>

    <!-- ***************************************************************************************************** -->

    <table width="90%" cellspacing="0" cellpadding="3" id="everyday_PL-table" style="display:none" >
      <caption align="center" class="title">
        每日盈亏统计
      </caption>
      <tr align="center">
        <td>
        <!-- {foreach from=$profit item=item key=key} -->
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block;margin: 10px 20px;" class="stable">
            <caption style="background:#DDEEF2; font-weight: bold; font-size: 20px;">{$item.area}</caption>
            <tr>
              <th>日期</th><th>总金额</th><th>产品成本</th><th>纸箱成本</th>
              <th>包装成本</th><th>快递成本</th><th>毛利润</th><th bgcolor="#9CCBD6">纯利润</th>
              <th>盈单数</th><th bgcolor="#9CCBD6">盈利金额</th><th>亏单数</th><th bgcolor="#9CCBD6">亏损金额</th>
            </tr>
            <!-- {foreach from=$item.summary item=item key=key} -->
            <tr>
              <td>{$item.order_sn}</td><td>{$item.order_amount}</td><td>{$item.xprice}</td><td>{$item.box}</td>
              <td>{$item.package}</td><td>{$item.shipping_fee}</td><td>{$item.gross}</td><td bgcolor="#9CCBD6">{$item.pure}</td>
              <td>{$item.profit}</td><td bgcolor="#9CCBD6">{$item.profit_pure}</td><td>{$item.deficit}</td><td bgcolor="#9CCBD6">{$item.deficit_pure}</td>
            </tr>
            <!-- {/foreach}-->
          </table>
          <!-- {/foreach}-->
        </td>
      </tr>
      <!-- ***************详细****************-->
      <tr align="center" style="display:inline-block; margin-left: 50px">
  <!--盈单-->
        <td style=" vertical-align: top;">
        <!-- {foreach from=$profit item=item key=key} -->
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block;margin: 10px 0 0 20px; vertical-align: top;" >
              <caption style="background:#DDEEF2; font-weight: bold; font-size: 20px;">{$item.area} 盈单列表</caption>
            <tr>
              <th>订单号</th><th>总金额</th><th>产品成本</th><th>纸箱成本</th>
              <th>包装成本</th><th>快递成本</th><th>毛利润</th><th>纯利润</th>
            </tr>
  
            <!-- {foreach from=$item.profit item=item key=key} -->
            <tr>
              <td><a href="http://www.eggms.com/73ycadmin/order_detail.php?act=detail&order_id={$item.order_id}" target="_blank">{$item.order_sn}</a></td><td>{$item.order_amount}</td><td>{$item.xprice}</td><td>{$item.box}</td>
              <td>{$item.package}</td><td>{$item.shipping_fee}</td><td>{$item.gross}</td><td>{$item.pure}</td>
            </tr>
            <!-- {/foreach}-->
          </table>
          <!--{/foreach}-->
        </td>
  <!--亏单-->
        <td style=" vertical-align: top;">
        <!-- {foreach from=$profit item=item key=key} -->
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block; margin: 10px 0 0 20px; " >
              <caption style="background:#DDEEF2; font-weight: bold; font-size: 20px;">{$item.area} 亏单列表</caption>
            <tr>
              <th>订单号</th><th>总金额</th><th>产品成本</th><th>纸箱成本</th>
              <th>包装成本</th><th>快递成本</th><th>毛利润</th><th>纯利润</th>
            </tr>
  
            <!-- {foreach from=$item.deficit item=item key=key} -->
            <tr {if $item.order_amount < $item.xprice}bgcolor="#9CCBD6"{/if} {if $item.order_amount eq 0 and $item.xprice eq 0}bgcolor="red"{/if}>
              <td><a href="http://www.eggms.com/73ycadmin/order_detail.php?act=detail&order_id={$item.order_id}" target="_blank">{$item.order_sn}</a></td><td>{$item.order_amount}</td><td>{$item.xprice}</td><td>{$item.box}</td>
              <td>{$item.package}</td><td>{$item.shipping_fee}</td><td>{$item.gross}</td><td>{$item.pure}</td>
            </tr>
            <tr style="display: none"><td><xxx</td></tr>
            <!-- {/foreach}-->
          </table>
          <!--{/foreach}-->
        </td>
      </tr>
    </table>
    <!-- ***************************************************************************************************** -->
    <table width="90%" cellspacing="0" cellpadding="3" id="weight_region-table" style="display:none">
      <caption align="center" class="title">
        重量地区分布
      </caption>
      <tr align="center">
      </tr>
    </table>
    <!-- ***************************************************************************************************** -->
    <table width="90%" cellspacing="0" cellpadding="3" id="pay_region-table" style="display:none" class="stable">
      <caption align="center" class="title">
        支付地区分布
      </caption>
      <tr align="center">
        <td valign="top" style="text-align: center;">
          {foreach from=$pay_region item=item key=key}
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block;margin: 10px 20px;" >
            <tr>
              <th width="25%" bgcolor="#DDEEF2">{$item.area}</th><th width="25%">数量</th><th width="25%">占有率</th><th width="25%">占全国比率</th>
            </tr>
            {foreach from=$item.pay item=i key=k}
            <tr>
              <td>{$i.pay_name}</td>
              <td>{$i.count}</td>
              <td>{$i.pct}</td>
              <td>{$i.pct_all}</td>
            </tr>
            {/foreach}
            <tr>
              <td>单量</td><td>{$item.count}</td><td>{$item.pct}</td><td>{$item.pct}</td>
            </tr>
          </table>
          {/foreach}
        </td>  
      </tr>
    </table>
    <!-- ***************************************************************************************************** -->
    <table width="90%" cellspacing="0" cellpadding="3" id="trench_region-table" style="display:none" border="1" class="stable">
      <caption align="center" class="title">
        购买渠道分析
      </caption>
      <tr bgcolor="#DDEEF2">
        <th></th><th>方式</th><th>用户下单量</th><th>淘宝订单量</th><th>商城客服下单量</th>
      </tr>
      {foreach from=$buy_way item=item key=key}
      <tr align="center">
        <td>{$item.region}</td><td>订单数</td><td>{$item.stats.0.cnt}</td>
        <td>{$item.stats.1.cnt}</td><td>{$item.stats.2.cnt}</td>
      </tr>
      <tr align="center" bgcolor="#9CCBD6">
        <td></td><td>金额</td><td>{$item.stats.0.amount}</td><td>{$item.stats.1.amount}</td><td>{$item.stats.2.amount}</td>
      </tr>
      {/foreach}
    </table>
    <!-- ***************************************************************************************************** -->
    <table width="90%" cellspacing="0" cellpadding="3" id="profit_time_region-table" style="display:none" >
      <caption align="center" class="title">
        用户统计分析
      </caption>
      <tr align="center">
        <td>
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block;margin: 10px 20px;" class="stable">
            <caption style="background:#DDEEF2; font-weight: bold; font-size: 20px;">新增有效用户统计</caption>
            <tr >
              <th width="25%" >日期</th><th width="25%">第一次购买的用户数</th>
            </tr>
            {foreach from=$user_stats item=item key=key}
            <tr align="center">
              <td>{if $key eq 'all'}汇总{else}{$key}{/if}</td>
              <td>{$item.count}</td>
            </tr>
            {/foreach}
          </table>
        </td>
  
      <!--用户购买次数统计-->
      
        <td>
          <table cellspacing="0" border="1" cellpadding="3" style="display: inline-block;margin: 10px 20px;" class="stable">
            <caption style="background:#DDEEF2; font-weight: bold; font-size: 20px;">用户购买次数统计</caption>
            <tr >
              <th width="25%" >购买次数</th><th width="25%">人数</th>
            </tr>
            {foreach from=$user_buy_count item=item key=key}
            <tr align="center">
              <td>{$item.cnt}</td>
              <td>{$item.counts}</td>
            </tr>
            {/foreach}
          </table>
        </td>
      </tr>
      <tr align="center">
        <td>说明：通过淘宝下单或客服下单的客户没有计算在内</td>
        <td>说明：最后两行分别为商城客服下单和淘宝下单</td>
      </tr>
    </table>
 </div>
</div>
{insert_scripts files="tab.js"}
<script language="JavaScript">
onload = function()
{
    // 开始检查订单
  startCheckOrder();
}
</script>
{include file="pagefooter.htm"}